import {
  Anthropic,
  Azure,
  Cohere,
  Deepseek,
  GoogleLogo,
  Lingyiwanwu,
  Mistral,
  Openai,
  Qwen,
  Zhipu,
  Xai,
  Ollama,
} from '@teable/icons';
import { LLMProviderType } from '@teable/openapi';

export const LLM_PROVIDER_ICONS = {
  [LLMProviderType.OPENAI]: Openai,
  [LLMProviderType.ANTHROPIC]: Anthropic,
  [LLMProviderType.GOOGLE]: GoogleLogo,
  [LLMProviderType.AZURE]: Azure,
  [LLMProviderType.COHERE]: Cohere,
  [LLMProviderType.MISTRAL]: Mistral,
  [LLMProviderType.DEEPSEEK]: Deepseek,
  [LLMProviderType.QWEN]: Qwen,
  [LLMProviderType.ZHIPU]: Zhipu,
  [LLMProviderType.LINGYIWANWU]: Lingyiwanwu,
  [LLMProviderType.XAI]: Xai,
  [LLMProviderType.TOGETHERAI]: Openai,
  [LLMProviderType.OLLAMA]: Ollama,
};

export const LLM_PROVIDERS = [
  {
    value: LLMProviderType.DEEPSEEK,
    label: 'DeepSeek',
    baseUrlPlaceholder: 'https://api.deepseek.ai/v1',
    modelsPlaceholder: 'deepseek-chat,deepseek-reasoner,deepseek-coder',
    Icon: LLM_PROVIDER_ICONS[LLMProviderType.DEEPSEEK],
  },
  {
    value: LLMProviderType.OPENAI,
    label: 'OpenAI',
    baseUrlPlaceholder: 'https://api.openai.com/v1',
    modelsPlaceholder: 'gpt-4,gpt-4o-mini,gpt-3.5-turbo',
    Icon: LLM_PROVIDER_ICONS[LLMProviderType.OPENAI],
  },
  {
    value: LLMProviderType.ANTHROPIC,
    label: 'Anthropic',
    baseUrlPlaceholder: 'https://api.anthropic.com',
    modelsPlaceholder: 'claude-3-opus-20240229,claude-3-5-sonnet-20241022',
    Icon: LLM_PROVIDER_ICONS[LLMProviderType.ANTHROPIC],
  },
  {
    value: LLMProviderType.GOOGLE,
    label: 'Google',
    baseUrlPlaceholder: 'https://generativelanguage.googleapis.com',
    modelsPlaceholder: 'gemini-pro-vision,gemini-1.5-flash-002',
    Icon: LLM_PROVIDER_ICONS[LLMProviderType.GOOGLE],
  },
  {
    value: LLMProviderType.AZURE,
    label: 'Azure',
    baseUrlPlaceholder: 'https://{your-resource-name}.openai.azure.com',
    modelsPlaceholder: 'gpt-4,gpt-35-turbo',
    Icon: LLM_PROVIDER_ICONS[LLMProviderType.AZURE],
  },
  {
    value: LLMProviderType.COHERE,
    label: 'Cohere',
    baseUrlPlaceholder: 'https://api.cohere.ai/v1',
    modelsPlaceholder: 'command-r,command-r-plus,command-r-plus-online',
    Icon: LLM_PROVIDER_ICONS[LLMProviderType.COHERE],
  },
  {
    value: LLMProviderType.MISTRAL,
    label: 'Mistral',
    baseUrlPlaceholder: 'https://api.mistral.ai/v1',
    modelsPlaceholder: 'mistral-large-latest,open-mistral-nemo',
    Icon: LLM_PROVIDER_ICONS[LLMProviderType.MISTRAL],
  },
  {
    value: LLMProviderType.QWEN,
    label: 'Qwen',
    baseUrlPlaceholder: 'https://dashscope.aliyuncs.com/compatible-mode/v1',
    modelsPlaceholder: 'qwen-plus,qwen-plus,qwen-max',
    Icon: LLM_PROVIDER_ICONS[LLMProviderType.QWEN],
  },
  {
    value: LLMProviderType.ZHIPU,
    label: 'Zhipu',
    baseUrlPlaceholder: 'https://open.bigmodel.cn/api/paas/v4',
    modelsPlaceholder: 'glm-3-turbo,glm-4,glm-4-air',
    Icon: LLM_PROVIDER_ICONS[LLMProviderType.ZHIPU],
  },
  {
    value: LLMProviderType.LINGYIWANWU,
    label: 'Yi',
    baseUrlPlaceholder: 'https://api.lingyiwanwu.com/v1',
    modelsPlaceholder: 'yi-lightning,yi-large',
    Icon: LLM_PROVIDER_ICONS[LLMProviderType.LINGYIWANWU],
  },
  {
    value: LLMProviderType.XAI,
    label: 'XAI',
    baseUrlPlaceholder: 'https://api.x.ai/v1',
    modelsPlaceholder: 'grok-2,grok-3,grok-3-reasoner',
    Icon: LLM_PROVIDER_ICONS[LLMProviderType.XAI],
  },
  {
    value: LLMProviderType.TOGETHERAI,
    label: 'TogetherAI',
    baseUrlPlaceholder: 'https://api.together.xyz/v1',
    modelsPlaceholder: 'deepseek-ai/DeepSeek-V3,mistralai/Mistral-7B-Instruct-v0.3',
    Icon: LLM_PROVIDER_ICONS[LLMProviderType.TOGETHERAI],
  },
  {
    value: LLMProviderType.OLLAMA,
    label: 'Ollama',
    baseUrlPlaceholder: 'http://localhost:11434',
    modelsPlaceholder: 'llama3.1:8b,llama3.1:70b',
    Icon: LLM_PROVIDER_ICONS[LLMProviderType.OLLAMA],
  },
] as const;
